<?php

namespace Rjyst\ApiInvoke;

use Illuminate\Support\ServiceProvider;

class ApiInvokeServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        // 发布路由文件
        $this->publishes([
            __DIR__.'/../stubs/routes/' => base_path('routes')
        ], 'api-invoke-routes');

        // 发布API控制器文件
        $this->publishes([
            __DIR__.'/../stubs/Http/Controllers/' => app_path('Http/Controllers/Api')
        ], 'api-invoke-controllers');

        // 发布中间件文件
        $this->publishes([
            __DIR__.'/../stubs/Http/Middleware/' => app_path('Http/Middleware')
        ], 'api-invoke-middleware');

        // 发布枚举文件
        $this->publishes([
            __DIR__.'/../stubs/Enums/' => app_path('Enums')
        ], 'api-invoke-enums');

        // 发布工厂文件
        $this->publishes([
            __DIR__.'/../stubs/Factory/' => app_path('Factory')
        ], 'api-invoke-factory');

        // 发布异常处理文件
        $this->publishes([
            __DIR__.'/../stubs/Exceptions/' => app_path('Exceptions')
        ], 'api-invoke-exceptions');

        // 发布内核文件
        $this->publishes([
            __DIR__.'/../stubs/Http/Kernel.php' => app_path('Http/Kernel.php')
        ], 'api-invoke-kernel');

        // 发布助手函数
        $this->publishes([
            __DIR__.'/../stubs/helpers.php' => app_path('helpers.php')
        ], 'api-invoke-helpers');

        // 注册 Artisan 命令
        if ($this->app->runningInConsole()) {
            $this->commands([
                Console\Commands\InstallCommand::class,
                Console\Commands\UninstallCommand::class,
            ]);
        }
    }
}
